package com.tledu.spring.core.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;

/**
 * @Author: rupert-tears
 * @Date: Created in 15:21 2021/7/8
 * @Description: 优秀的人都在孤独的翻山越岭！
 */
@Component
public class DateFormat {
    /**
     * 全局拦截
     * @return 格式化后的时间
     */
    @Bean
    public ObjectMapper getObjectMapper(){
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
        return objectMapper;
    }
}
